package com.itboye.textileexpres.myset;

import android.R.integer;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;

import com.itboye.textileexpes.beans.AppUpdateBean;
import com.itboye.textileexpres.R;
import com.itboye.textileexpres.base.BaseActivity;
import com.itboye.textileexpres.base.MainApplication;
import com.itboye.textileexpres.base.SpPublicParams;
import com.itboye.textileexpres.util.IsMobileNumPhone;
import com.itboye.textileexpres.util.SPUtils;

public class ActivityFavorite extends BaseActivity implements OnClickListener {
	TextView title;
	ImageView back, img_other;
	ToggleButton version_toggle_button, message_toggle_button;
	RelativeLayout textSize_rel, language_rel;
	AppUpdateBean bean = new AppUpdateBean();
	String ischekd;
	String istrue;
	String isfalse;

	@Override
	public int initView() {
		// TODO Auto-generated method stub
		return R.layout.activity_favorite;
	}

	@Override
	public void onMyCreate() {
		// TODO Auto-generated method stub
		title.setText(R.string.favorite);
		img_other.setVisibility(View.GONE);
		SharedPrefer();

	}

	/**
	 * 判断是否是第一进入，加入是则强制设置为true否则执行缓存判断，根据缓存数据设置false还是true
	 */
	private void SharedPrefer() {
		if (IsMobileNumPhone.isCheckd().equals("1")) {
			version_toggle_button.setChecked(true);
		} else if (IsMobileNumPhone.isUid() == null) {
			version_toggle_button.setChecked(true);
		} else {
			version_toggle_button.setChecked(false);
		}

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.back:
			finish();
			break;
		case R.id.textSize_rel:
			Intent intent = new Intent(this, ActivityTextSize.class);
			startActivity(intent);
			break;
		case R.id.language_rel:
			// Intent intent2 = new Intent(this, ActivityLanguageChange.class);
			Intent intent2 = new Intent(this, ActivityLanguage.class);
			startActivity(intent2);
			break;
		// case R.id.message_toggle_button:
		// if (message_toggle_button.isChecked()==true) {
		// SPUtils.put(MainApplication.getContext(), null, ap, object);
		// }
		//
		// break;
		case R.id.version_toggle_button:
			if (version_toggle_button.isChecked() == true) {
				SPUtils.put(MainApplication.context, null,
						SpPublicParams.ISCHECKD, "1");
			} else {
				SPUtils.put(MainApplication.context, null,
						SpPublicParams.ISCHECKD, "2");
			}

			break;
		}
	}
}
